package com.sojson.config.swagger;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Component;

import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.schema.ModelPropertyBuilderPlugin;
import springfox.documentation.spi.schema.contexts.ModelPropertyContext;
import springfox.documentation.swagger.common.SwaggerPluginSupport;

/**
 * Swagger字段排序
 * 
 * @author liu
 * @date 2021-05-17
 */
@Component
public class CustomApiModelPropertyPositionBuilder implements ModelPropertyBuilderPlugin {

    /** 不参与排序的字段集合 */
    private List<String> fieldNamesNo = new ArrayList<>();

    {
        fieldNamesNo.add("id");
        fieldNamesNo.add("pageNum");
        fieldNamesNo.add("pageSize");
        fieldNamesNo.add("orderByColumn");
    }

    @Override
    public void apply(ModelPropertyContext context) {}

    @Override
    public boolean supports(DocumentationType delimiter) {
        return SwaggerPluginSupport.pluginDoesApply(delimiter);
    }

}